package opreation.impl;

import book.Book;
import book.BookList;
import opreation.IOperation;

//借阅书籍
public class BorrowOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
        System.out.print("请输入您想要借阅的书籍：");
        String name = scanner.next();
        //检查书籍是否存在
        if(bookList.contains(name)) {
            //获取对应的书籍
            Book book = bookList.findBook(name);
            if (!book.isBorrowed()){
                book.setBorrowed(true);
                System.out.println("借阅成功！");
            }else{
                System.out.println("该书已被借走！");
            }
        }else{
            System.out.println("没有找到您想要的书籍！");
        }
    }
}
